package com.atguigu.jxc.controller;

import com.atguigu.jxc.entity.Unit;
import com.atguigu.jxc.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author luojia
 * @create 2022-01-03 19:13
 */
@RestController
@RequestMapping("unit")
public class UnitController {
    @Autowired
    private GoodsService goodsService;
    /**
     * 返回商品的单位
     * @return
     */
    @PostMapping("list")
    public Map<String,Object> queryUnit(){
        List<Unit> units = this.goodsService.queryUnit();
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("rows",units);
        return hashMap;
    }
}
